package com.woniu.register.config;

import com.alibaba.druid.pool.DruidDataSource;
import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @program: house-after
 * @description:
 * @author: qqq
 * @create: 2022-12-15 15:55
 **/

@Configuration
public class DataSourceProxyConfig {
    @Primary//让其他地方优先使用此数据源
    @Bean
    @ConfigurationProperties(prefix = "spring.datasource")
    public DruidDataSource druidDataSource() {
        return new DruidDataSource();
    }
    @Bean
    public DataSourceProxy dataSource(DruidDataSource druidDataSource) {
        System.out.println(druidDataSource);
        return new DataSourceProxy(druidDataSource);
    }
}
